.class public Lcom/vividsolutions/jts/index/quadtree/Node;
.super Lcom/vividsolutions/jts/index/quadtree/NodeBase;
.source "Node.java"


# instance fields
.field private centre:Lcom/vividsolutions/jts/geom/Coordinate;

.field private env:Lcom/vividsolutions/jts/geom/Envelope;

.field private level:I


# direct methods
.method public constructor <init>(Lcom/vividsolutions/jts/geom/Envelope;I)V
    .locals 6

    .line 72
    invoke-direct {p0}, Lcom/vividsolutions/jts/index/quadtree/NodeBase;-><init>()V

    .line 74
    iput-object p1, p0, Lcom/vividsolutions/jts/index/quadtree/Node;->env:Lcom/vividsolutions/jts/geom/Envelope;

    .line 75
    iput p2, p0, Lcom/vividsolutions/jts/index/quadtree/Node;->level:I

    .line 76
    new-instance p2, Lcom/vividsolutions/jts/geom/Coordinate;

    invoke-direct {p2}, Lcom/vividsolutions/jts/geom/Coordinate;-><init>()V

    iput-object p2, p0, Lcom/vividsolutions/jts/index/quadtree/Node;->centre:Lcom/vividsolutions/jts/geom/Coordinate;

    .line 77
    iget-object p2, p0, Lcom/vividsolutions/jts/index/quadtree/Node;->centre:Lcom/vividsolutions/jts/geom/Coordinate;

    invoke-virtual {p1}, Lcom/vividsolutions/jts/geom/Envelope;->getMinX()D

    move-result-wide v0

    invoke-virtual {p1}, Lcom/vividsolutions/jts/geom/Envelope;->getMaxX()D

    move-result-wide v2

    add-double/2addr v0, v2

    const-wide/high16 v2, 0x4000000000000000L    # 2.0

    div-double/2addr v0, v2

    iput-wide v0, p2, Lcom/vividsolutions/jts/geom/Coordinate;->x:D

    .line 78
    iget-object p2, p0, Lcom/vividsolutions/jts/index/quadtree/Node;->centre:Lcom/vividsolutions/jts/geom/Coordinate;

    invoke-virtual {p1}, Lcom/vividsolutions/jts/geom/Envelope;->getMinY()D

    move-result-wide v0

    invoke-virtual {p1}, Lcom/vividsolutions/jts/geom/Envelope;->getMaxY()D

    move-result-wide v4

    add-double/2addr v0, v4

    div-double/2addr v0, v2

    iput-wide v0, p2, Lcom/vividsolutions/jts/geom/Coordinate;->y:D

    return-void
.end method

.method public static createExpanded(Lcom/vividsolutions/jts/index/quadtree/Node;Lcom/vividsolutions/jts/geom/Envelope;)Lcom/vividsolutions/jts/index/quadtree/Node;
    .locals 1

    .line 59
    new-instance v0, Lcom/vividsolutions/jts/geom/Envelope;

    invoke-direct {v0, p1}, Lcom/vividsolutions/jts/geom/Envelope;-><init>(Lcom/vividsolutions/jts/geom/Envelope;)V

    if-eqz p0, :cond_0

    .line 60
    iget-object p1, p0, Lcom/vividsolutions/jts/index/quadtree/Node;->env:Lcom/vividsolutions/jts/geom/Envelope;

    invoke-virtual {v0, p1}, Lcom/vividsolutions/jts/geom/Envelope;->expandToInclude(Lcom/vividsolutions/jts/geom/Envelope;)V

    .line 62
    :cond_0
    invoke-static {v0}, Lcom/vividsolutions/jts/index/quadtree/Node;->createNode(Lcom/vividsolutions/jts/geom/Envelope;)Lcom/vividsolutions/jts/index/quadtree/Node;

    move-result-object p1

    if-eqz p0, :cond_1

    .line 63
    invoke-virtual {p1, p0}, Lcom/vividsolutions/jts/index/quadtree/Node;->insertNode(Lcom/vividsolutions/jts/index/quadtree/Node;)V

    :cond_1
    return-object p1
.end method

.method public static createNode(Lcom/vividsolutions/jts/geom/Envelope;)Lcom/vividsolutions/jts/index/quadtree/Node;
    .locals 2

    .line 52
    new-instance v0, Lcom/vividsolutions/jts/index/quadtree/Key;

    invoke-direct {v0, p0}, Lcom/vividsolutions/jts/index/quadtree/Key;-><init>(Lcom/vividsolutions/jts/geom/Envelope;)V

    .line 53
    new-instance p0, Lcom/vividsolutions/jts/index/quadtree/Node;

    invoke-virtual {v0}, Lcom/vividsolutions/jts/index/quadtree/Key;->getEnvelope()Lcom/vividsolutions/jts/geom/Envelope;

    move-result-object v1

    invoke-virtual {v0}, Lcom/vividsolutions/jts/index/quadtree/Key;->getLevel()I

    move-result v0

    invoke-direct {p0, v1, v0}, Lcom/vividsolutions/jts/index/quadtree/Node;-><init>(Lcom/vividsolutions/jts/geom/Envelope;I)V

    return-object p0
.end method

.method private createSubnode(I)Lcom/vividsolutions/jts/index/quadtree/Node;
    .locals 20

    move-object/from16 v0, p0

    move/from16 v1, p1

    const/4 v2, 0x1

    const-wide/16 v3, 0x0

    if-eqz v1, :cond_3

    if-eq v1, v2, :cond_2

    const/4 v5, 0x2

    if-eq v1, v5, :cond_1

    const/4 v5, 0x3

    if-eq v1, v5, :cond_0

    move-wide v12, v3

    move-wide v14, v12

    move-wide/from16 v16, v14

    move-wide/from16 v18, v16

    goto :goto_1

    .line 187
    :cond_0
    iget-object v1, v0, Lcom/vividsolutions/jts/index/quadtree/Node;->centre:Lcom/vividsolutions/jts/geom/Coordinate;

    iget-wide v3, v1, Lcom/vividsolutions/jts/geom/Coordinate;->x:D

    .line 188
    iget-object v1, v0, Lcom/vividsolutions/jts/index/quadtree/Node;->env:Lcom/vividsolutions/jts/geom/Envelope;

    invoke-virtual {v1}, Lcom/vividsolutions/jts/geom/Envelope;->getMaxX()D

    move-result-wide v5

    .line 189
    iget-object v1, v0, Lcom/vividsolutions/jts/index/quadtree/Node;->centre:Lcom/vividsolutions/jts/geom/Coordinate;

    iget-wide v7, v1, Lcom/vividsolutions/jts/geom/Coordinate;->y:D

    .line 190
    iget-object v1, v0, Lcom/vividsolutions/jts/index/quadtree/Node;->env:Lcom/vividsolutions/jts/geom/Envelope;

    invoke-virtual {v1}, Lcom/vividsolutions/jts/geom/Envelope;->getMaxY()D

    move-result-wide v9

    goto :goto_0

    .line 181
    :cond_1
    iget-object v1, v0, Lcom/vividsolutions/jts/index/quadtree/Node;->env:Lcom/vividsolutions/jts/geom/Envelope;

    invoke-virtual {v1}, Lcom/vividsolutions/jts/geom/Envelope;->getMinX()D

    move-result-wide v3

    .line 182
    iget-object v1, v0, Lcom/vividsolutions/jts/index/quadtree/Node;->centre:Lcom/vividsolutions/jts/geom/Coordinate;

    iget-wide v5, v1, Lcom/vividsolutions/jts/geom/Coordinate;->x:D

    .line 183
    iget-wide v7, v1, Lcom/vividsolutions/jts/geom/Coordinate;->y:D

    .line 184
    iget-object v1, v0, Lcom/vividsolutions/jts/index/quadtree/Node;->env:Lcom/vividsolutions/jts/geom/Envelope;

    invoke-virtual {v1}, Lcom/vividsolutions/jts/geom/Envelope;->getMaxY()D

    move-result-wide v9

    goto :goto_0

    .line 175
    :cond_2
    iget-object v1, v0, Lcom/vividsolutions/jts/index/quadtree/Node;->centre:Lcom/vividsolutions/jts/geom/Coordinate;

    iget-wide v3, v1, Lcom/vividsolutions/jts/geom/Coordinate;->x:D

    .line 176
    iget-object v1, v0, Lcom/vividsolutions/jts/index/quadtree/Node;->env:Lcom/vividsolutions/jts/geom/Envelope;

    invoke-virtual {v1}, Lcom/vividsolutions/jts/geom/Envelope;->getMaxX()D

    move-result-wide v5

    .line 177
    iget-object v1, v0, Lcom/vividsolutions/jts/index/quadtree/Node;->env:Lcom/vividsolutions/jts/geom/Envelope;

    invoke-virtual {v1}, Lcom/vividsolutions/jts/geom/Envelope;->getMinY()D

    move-result-wide v7

    .line 178
    iget-object v1, v0, Lcom/vividsolutions/jts/index/quadtree/Node;->centre:Lcom/vividsolutions/jts/geom/Coordinate;

    iget-wide v9, v1, Lcom/vividsolutions/jts/geom/Coordinate;->y:D

    goto :goto_0

    .line 169
    :cond_3
    iget-object v1, v0, Lcom/vividsolutions/jts/index/quadtree/Node;->env:Lcom/vividsolutions/jts/geom/Envelope;

    invoke-virtual {v1}, Lcom/vividsolutions/jts/geom/Envelope;->getMinX()D

    move-result-wide v3

    .line 170
    iget-object v1, v0, Lcom/vividsolutions/jts/index/quadtree/Node;->centre:Lcom/vividsolutions/jts/geom/Coordinate;

    iget-wide v5, v1, Lcom/vividsolutions/jts/geom/Coordinate;->x:D

    .line 171
    iget-object v1, v0, Lcom/vividsolutions/jts/index/quadtree/Node;->env:Lcom/vividsolutions/jts/geom/Envelope;

    invoke-virtual {v1}, Lcom/vividsolutions/jts/geom/Envelope;->getMinY()D

    move-result-wide v7

    .line 172
    iget-object v1, v0, Lcom/vividsolutions/jts/index/quadtree/Node;->centre:Lcom/vividsolutions/jts/geom/Coordinate;

    iget-wide v9, v1, Lcom/vividsolutions/jts/geom/Coordinate;->y:D

    :goto_0
    move-wide v12, v3

    move-wide v14, v5

    move-wide/from16 v16, v7

    move-wide/from16 v18, v9

    .line 193
    :goto_1
    new-instance v1, Lcom/vividsolutions/jts/geom/Envelope;

    move-object v11, v1

    invoke-direct/range {v11 .. v19}, Lcom/vividsolutions/jts/geom/Envelope;-><init>(DDDD)V

    .line 194
    new-instance v3, Lcom/vividsolutions/jts/index/quadtree/Node;

    iget v4, v0, Lcom/vividsolutions/jts/index/quadtree/Node;->level:I

    sub-int/2addr v4, v2

    invoke-direct {v3, v1, v4}, Lcom/vividsolutions/jts/index/quadtree/Node;-><init>(Lcom/vividsolutions/jts/geom/Envelope;I)V

    return-object v3
.end method

.method private getSubnode(I)Lcom/vividsolutions/jts/index/quadtree/Node;
    .locals 2

    .line 152
    iget-object v0, p0, Lcom/vividsolutions/jts/index/quadtree/NodeBase;->subnode:[Lcom/vividsolutions/jts/index/quadtree/Node;

    aget-object v1, v0, p1

    if-nez v1, :cond_0

    .line 153
    invoke-direct {p0, p1}, Lcom/vividsolutions/jts/index/quadtree/Node;->createSubnode(I)Lcom/vividsolutions/jts/index/quadtree/Node;

    move-result-object v1

    aput-object v1, v0, p1

    .line 155
    :cond_0
    iget-object v0, p0, Lcom/vividsolutions/jts/index/quadtree/NodeBase;->subnode:[Lcom/vividsolutions/jts/index/quadtree/Node;

    aget-object p1, v0, p1

    return-object p1
.end method


# virtual methods
.method public find(Lcom/vividsolutions/jts/geom/Envelope;)Lcom/vividsolutions/jts/index/quadtree/NodeBase;
    .locals 3

    .line 114
    iget-object v0, p0, Lcom/vividsolutions/jts/index/quadtree/Node;->centre:Lcom/vividsolutions/jts/geom/Coordinate;

    invoke-static {p1, v0}, Lcom/vividsolutions/jts/index/quadtree/NodeBase;->getSubnodeIndex(Lcom/vividsolutions/jts/geom/Envelope;Lcom/vividsolutions/jts/geom/Coordinate;)I

    move-result v0

    const/4 v1, -0x1

    if-ne v0, v1, :cond_0

    return-object p0

    .line 117
    :cond_0
    iget-object v1, p0, Lcom/vividsolutions/jts/index/quadtree/NodeBase;->subnode:[Lcom/vividsolutions/jts/index/quadtree/Node;

    aget-object v2, v1, v0

    if-eqz v2, :cond_1

    .line 119
    aget-object v0, v1, v0

    .line 120
    invoke-virtual {v0, p1}, Lcom/vividsolutions/jts/index/quadtree/Node;->find(Lcom/vividsolutions/jts/geom/Envelope;)Lcom/vividsolutions/jts/index/quadtree/NodeBase;

    move-result-object p1

    return-object p1

    :cond_1
    return-object p0
.end method

.method public getEnvelope()Lcom/vividsolutions/jts/geom/Envelope;
    .locals 1

    .line 81
    iget-object v0, p0, Lcom/vividsolutions/jts/index/quadtree/Node;->env:Lcom/vividsolutions/jts/geom/Envelope;

    return-object v0
.end method

.method public getNode(Lcom/vividsolutions/jts/geom/Envelope;)Lcom/vividsolutions/jts/index/quadtree/Node;
    .locals 2

    .line 95
    iget-object v0, p0, Lcom/vividsolutions/jts/index/quadtree/Node;->centre:Lcom/vividsolutions/jts/geom/Coordinate;

    invoke-static {p1, v0}, Lcom/vividsolutions/jts/index/quadtree/NodeBase;->getSubnodeIndex(Lcom/vividsolutions/jts/geom/Envelope;Lcom/vividsolutions/jts/geom/Coordinate;)I

    move-result v0

    const/4 v1, -0x1

    if-eq v0, v1, :cond_0

    .line 99
    invoke-direct {p0, v0}, Lcom/vividsolutions/jts/index/quadtree/Node;->getSubnode(I)Lcom/vividsolutions/jts/index/quadtree/Node;

    move-result-object v0

    .line 101
    invoke-virtual {v0, p1}, Lcom/vividsolutions/jts/index/quadtree/Node;->getNode(Lcom/vividsolutions/jts/geom/Envelope;)Lcom/vividsolutions/jts/index/quadtree/Node;

    move-result-object p1

    return-object p1

    :cond_0
    return-object p0
.end method

.method insertNode(Lcom/vividsolutions/jts/index/quadtree/Node;)V
    .locals 4

    .line 128
    iget-object v0, p0, Lcom/vividsolutions/jts/index/quadtree/Node;->env:Lcom/vividsolutions/jts/geom/Envelope;

    const/4 v1, 0x1

    if-eqz v0, :cond_1

    iget-object v2, p1, Lcom/vividsolutions/jts/index/quadtree/Node;->env:Lcom/vividsolutions/jts/geom/Envelope;

    invoke-virtual {v0, v2}, Lcom/vividsolutions/jts/geom/Envelope;->contains(Lcom/vividsolutions/jts/geom/Envelope;)Z

    move-result v0

    if-eqz v0, :cond_0

    goto :goto_0

    :cond_0
    const/4 v0, 0x0

    goto :goto_1

    :cond_1
    :goto_0
    const/4 v0, 0x1

    :goto_1
    invoke-static {v0}, Lcom/vividsolutions/jts/util/Assert;->isTrue(Z)V

    .line 131
    iget-object v0, p1, Lcom/vividsolutions/jts/index/quadtree/Node;->env:Lcom/vividsolutions/jts/geom/Envelope;

    iget-object v2, p0, Lcom/vividsolutions/jts/index/quadtree/Node;->centre:Lcom/vividsolutions/jts/geom/Coordinate;

    invoke-static {v0, v2}, Lcom/vividsolutions/jts/index/quadtree/NodeBase;->getSubnodeIndex(Lcom/vividsolutions/jts/geom/Envelope;Lcom/vividsolutions/jts/geom/Coordinate;)I

    move-result v0

    .line 133
    iget v2, p1, Lcom/vividsolutions/jts/index/quadtree/Node;->level:I

    iget v3, p0, Lcom/vividsolutions/jts/index/quadtree/Node;->level:I

    sub-int/2addr v3, v1

    if-ne v2, v3, :cond_2

    .line 134
    iget-object v1, p0, Lcom/vividsolutions/jts/index/quadtree/NodeBase;->subnode:[Lcom/vividsolutions/jts/index/quadtree/Node;

    aput-object p1, v1, v0

    goto :goto_2

    .line 140
    :cond_2
    invoke-direct {p0, v0}, Lcom/vividsolutions/jts/index/quadtree/Node;->createSubnode(I)Lcom/vividsolutions/jts/index/quadtree/Node;

    move-result-object v1

    .line 141
    invoke-virtual {v1, p1}, Lcom/vividsolutions/jts/index/quadtree/Node;->insertNode(Lcom/vividsolutions/jts/index/quadtree/Node;)V

    .line 142
    iget-object p1, p0, Lcom/vividsolutions/jts/index/quadtree/NodeBase;->subnode:[Lcom/vividsolutions/jts/index/quadtree/Node;

    aput-object v1, p1, v0

    :goto_2
    return-void
.end method

.method protected isSearchMatch(Lcom/vividsolutions/jts/geom/Envelope;)Z
    .locals 1

    .line 85
    iget-object v0, p0, Lcom/vividsolutions/jts/index/quadtree/Node;->env:Lcom/vividsolutions/jts/geom/Envelope;

    invoke-virtual {v0, p1}, Lcom/vividsolutions/jts/geom/Envelope;->intersects(Lcom/vividsolutions/jts/geom/Envelope;)Z

    move-result p1

    return p1
.end method
